package samples.stream;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.stream.BaseStream;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Arrays.asList;

public class OnCloseTest {

    final ReadWriteLock lock =null;

    private ArrayList productList = new ArrayList();

    @Test
    public void t1(){
       Stream.of("1","2","3","4","5") // Stream of List<Integer>
                .map(integer -> integer + 1)
                .onClose(() -> {
                    System.out.println("执行完毕");
                });
    }

//    public Stream readProducts() {
//        lock.readLock().lock();
//        return productList.stream().onClose(lock.readLock()::unlock);
//    }





}
